package cn.com.utt.unms.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.com.utt.unms.mapper.WxMarketingMapper;
import cn.com.utt.unms.pojo.WxMarketing;
import cn.com.utt.unms.service.WxMarketingService;

@Service("wxMarketingService")
public class WxMarketingServiceImpl implements WxMarketingService {

	@Autowired
	private WxMarketingMapper wxMarketingMapper;

	@Override
	@Transactional
	public WxMarketing queryMarketingByCfgId(long cfgId) {
		return wxMarketingMapper.queryMarketingByCfgId(cfgId);
	}

	@Override
	@Transactional
	public void updateMarketingByCfgId(WxMarketing wxMarketing, long cfgId) {

		// TODO 更新memcache中的认证配置
		// 先查询数据库中配置，比较有没有变化 ，有变化才需要修改页面
		WxMarketing info = wxMarketingMapper.queryMarketingByCfgId(cfgId);
		// 将最新数据同步到memcache中
		// wxConf.gets
		info.setKeyword(wxMarketing.getKeyword());
		info.setKeywordText(wxMarketing.getKeywordText());
		info.setAttentionText(wxMarketing.getAttentionText());
		info.setMsgText(wxMarketing.getMsgText());
		wxMarketingMapper.update(info);
	}

	@Override
	@Transactional
	public void save(WxMarketing wxMarketing) {
		wxMarketingMapper.save(wxMarketing);
	}

}
